<!-- userpermissions -->
<template>
  <div class="userpermissions">
    <el-form
      :model="form"
      status-icon
      :rules="rules"
      ref="form"
      label-width="100%"
      class="demo-ruleForm"
      :label-position="labelPosition"
    >
      <el-form-item label="用户名" prop="age">
        <el-input
          v-model.number="form.age"
          placeholder="请输入用户名"
        ></el-input>
      </el-form-item>
      <el-form-item label="权限">
        <el-select
          v-model="form.region"
          :popper-append-to-body="false"
          placeholder="请选择用户权限"
        >
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div class="form_btn">
      <div class="quxiao">取消</div>
      <div class="tijiao">提交</div>
    </div>
  </div>
</template>

<script>
/**
 * @name 用户权限
 */

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    var checkName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("用户名不能为空"));
      }
    };

    return {
      form: {
        name: "",
        region: "",
      },
      labelPosition: "top",
      rules: {
        name: [{ validator: checkName, trigger: "blur" }],
      },
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
  beforeCreate() {}, //生命周期 - 创建之前
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  beforeMount() {}, //生命周期 - 挂载之前
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="less" >
@import "../../assets/styles/frame.less";
.userpermissions {
  margin: auto;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 400px;
  height: 314px;
  padding: 37px 60px 46px;
  background: #ffffff;
  box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.13);
  border-radius: 14px;
  font-size: 14px;
  z-index: 9999;
  .form_btn {
    width: 100%;
    height: 40px;
    font-weight: 600;
    .divAJS();
    margin-top: 46px;
    .quxiao {
      width: 120px;
      height: 40px;
      background: #ffffff;
      border: 1px solid #cacaca;
      border-radius: 2px;
      .cen();
    }
    .tijiao {
      width: 120px;
      height: 40px;
      background: #3f3f3f;
      border-radius: 2px;
      color: #fff;
      .cen();
    }
  }
}
.el-select{
  width: 100% !important;
}
  
/deep/.el-select-dropdown__item {
  height: 100% !important;
}
.el-select-dropdown__item.selected {
    color: #2b2b2b;
    font-weight: 700;
}
</style>